<?php
class resource extends CI_Model{
	function artist($catalog,$start=0,$length=10,$search='',$locked=0){
		$this->load->model('artist');
    	$params=array('where'=>array('catalog'=>$catalog,'locked'=>$locked),'like'=>array(),'limit'=>array($start,$length),'order'=>array('sequence'=>'DESC','date'=>'DESC'));
		if($search!==''){
			$params['like']['name']=$search;
		}
		$return['TD']=reset($this->artist->get(array('select'=>'COUNT(*) AS TD','where'=>$params['where'],'like'=>$params['like'])));
		$return['TD']=$return['TD']['TD'];
		$return['RE']=$this->artist->get($params);
    	return $return;
	}
	function block($params){
		$this->load->model('block');
    	return true;
	}
	function catalog($params){
		$this->load->model('catalog');
    	return true;
	}
	function exhibit($params){
		$this->load->model('exhibit');
    	return true;
	}
	function image($params){
		$this->load->model('image');
    	return true;
	}
    function news($catalog,$start=0,$length=10,$search='',$release=false,$end=false,$locked=0){
    	$return=array();
    	$this->load->model('news');
    	$params=array('where'=>array('catalog'=>$catalog,'locked'=>$locked),'like'=>array(),'limit'=>array($start,$length),'order'=>array('sequence'=>'DESC','date'=>'DESC'));
		if($search!==''){
			$params['like']['caption']=$search;
		}
		if($start!==false&&$end!==false){
			$params['where']['release >=']=$release;
			$params['where']['release <=']=$end;
		}
		$return['TD']=reset($this->news->get(array('select'=>'COUNT(*) AS TD','where'=>$params['where'],'like'=>$params['like'])));
		$return['TD']=$return['TD']['TD'];
		$return['RE']=$this->news->get($params);
    	return $return;
    }
    function opus($params){
		$this->load->model('opus');
    	return true;
	}
	function publication($params){
		$this->load->model('publication');
    	return true;
	}
	function video($params=array()){
    	$this->load->model('video');
		return true;
    }
    function pagination($basic,$total,$per,$segment='srt'){
		$this->load->library('pagination',array(
			'base_url'=>$basic,
			'total_rows'=>$total,
			'per_page'=>$per,
			'full_tag_open'=>'<div class="fanyestyle">',
			'full_tag_close'=>'</div>',
			'anchor_class'=>'p_btn',
			'first_link'=>'第一页',
			'first_tag_open'=>'',
			'first_tag_close'=>'',
			'last_link'=>'最后页',
			'last_tag_open'=>'',
			'last_tag_close'=>'',
			'prev_link'=>false,
			'next_link'=>false,
			'cur_tag_open'=>'<a style="background-color:#898b8f;color:#e1e2e4;">',
			'cur_tag_close'=>'</a>',
			'page_query_string'=>true,
			'query_string_segment'=>$segment
		));
		return $this->pagination->create_links();
    }
}
?>